package com.sdu.shanyimisapi.controller.form;

import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * @author lihaopeng
 * @version 1.0
 * @project shanyi-mis-api
 * @description 用于查找用户的form类，接收前端传来的参数，用于分页查询
 * @since 2024/4/13 22:12
 */
@Data
public class SearchUserByPageForm {
    private Integer id;

    private String nickName;

    @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$", message = "name姓名内容不正确")
    private String name;

//    @Pattern(regexp = "^男$|^女$", message = "sex性别格式不正确，只能为男或女")
//    private String sex;

    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "phone手机号格式不正确")
    private String phone;

    @Pattern(regexp = "^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$", message = "email邮箱格式不正确")
    private String email;

    // @NotBlank注解只能用在字符串上，如果不是字符串类型，都可以使用@NotNull
    @NotNull(message = "status状态码不能为空")
    @Range(min = 0, max = 1, message = "status状态码不正确，0无效（逻辑删除），1有效")
    private Byte status;

    @Pattern(regexp = "^ASC$|^DESC$", message = "order排序字段不正确，只能为ASC（升序）或DESC（降序）")
    private String order;

    @NotNull(message = "page页码不能为空")
    @Min(value = 1, message = "page页码不能小于1")
    private Integer page;

    @NotNull(message = "length每页长度不能为空")
    @Range(min = 10, max = 50, message = "length每页长度不正确，最小10，最大50")
    private Integer length;


}
